/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myjme.appstate.plainappstate;

import com.jme3.math.FastMath;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer;
import com.jme3.util.BufferUtils;

/**
 *
 * @author Administrator
 */
public class MyJMECircle extends Mesh{
    private float radioX=0;
    private float radioY=0;
    private float xF=0;
    private float yF=0;
    public MyJMECircle(float radioX,float radioY){
        this.radioX=radioX;
        this.radioY=radioY;
        Vector3f [] vertices = new Vector3f[60];
        for(int i=0;i<60;i++){          
            if(i<30){
                xF=(float) (-radioX+0.1*radioX*i);
                yF=(float) FastMath.sqrt(radioY*radioY*(1-xF*xF/radioX/radioX));                
            }else{
                xF=(float) (radioX-(i-30)*0.1*radioX);
                yF=(float) -FastMath.sqrt(radioY*radioY*(1-xF*xF/radioX/radioX));
            }
            vertices[i] = new Vector3f(xF,yF,0);
        }

        this.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
//        this.setBuffer(VertexBuffer.Type.Index,    3, BufferUtils.createIntBuffer(indexes));
        this.setMode(Mesh.Mode.LineLoop);
        this.setStatic();
        this.updateBound();
    }
}
